
		
		//要用到的一些DOM对象
		var divPool = document.getElementById("pool"),
			divActive = document.getElementById("active"),
			divNext = document.getElementById("next")
		
		//总1、初始化
		//方块池子（从下到上 下标为:0到19）
		var oPool = new BlockPool(divPool),
			oActive = new ActiveBlock(divActive, oPool, divNext);

		oPool.initPool(4);
		newRound();

		/**
		 * 一轮新的回合。两个知识点
		 * 1、递归。通常是 for 循环改变条件结束递归，这里是用 setInterval 改变条件
		 * 2、setInterval
		 */
		function newRound(){
			oActive.next();

			// setInterval 让本轮活动方块自动走步，直到触底
			var t = setInterval(() => {
				// if(oActive.canMove('down')){
				// 	oActive.move('down');
				// }else{
				// 	//触底部
				// 	//1、结束本轮自动走步
				// 	clearInterval(t);
				// 	//2、更新池子数据
				// 	oActive.gotoPool();

				// 	//判断是否挂掉
				// 	var gameOver = oPool.isPoolTopDirty()
				// 	if(gameOver){
				// 		alert("GAME OVER !!");
				// 	}else{					
				// 		newRound();
				// 	}
				// }
				oActive.move('down', () => {
						//触底部
					//1、结束本轮自动走步
					clearInterval(t);
					//2、更新池子数据
					oActive.gotoPool();

					//判断是否挂掉
					var gameOver = oPool.isPoolTopDirty()
					if(gameOver){
						alert("GAME OVER !!");
					}else{					
						newRound();
					}
				})
			},600);

		}	
		
		//键盘事件 操作活动方块
		document.onkeydown = function(e){
			e = e || window.event;
			e.preventDefault();
			switch (e.keyCode)
			{
				case 37:
					// oActive.moveLeft();
					oActive.move('left');
					break;
				case 39:
					// oActive.moveRight();
					oActive.move('right');
					break;
				case 40:
					// oActive.moveDown();
					oActive.move('down');
					break;
				case 32:
					oActive.fallDown();
					break;
				case 38:
					oActive.rotate();
					break;
			}
		}